<?php 
//调用自动加载文件函数
require  __DIR__.'/../vendor/autoload.php';

// 调试工具
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();


use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Database\Capsule\Manager;


//创建服务容器
$container = new Container;

$request = Request::capture();
$container->instance('Illuminate\Http\Request', $request);

$events = new Dispatcher($container);
//创建路由实例
$router = new Router($events, $container);
//加载路由
require __DIR__.'/../app/routes.php';
//数据库配置
$databese = require __DIR__.'/../config/database.php';

//启动Eloquent ORM模块并进行相关配置
$manager = new Manager;
$manager->addConnection($databese['connections']['mysql']); //添加数据库连接配置文件
// 设置全局静态可访问DB
$manager->setAsGlobal();
// 启动Eloquent （如果只使用查询构造器，这个可以注释）
$manager->bootEloquent();

//请求分发处理程序
$response = $router->dispatch($request);

//返回请求的响应
$response->send();